<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script>
		window.onload=function () {
			var oBtn=document.getElementById('btn');
			oBtn.onclick=function(){
				var xhr=null;
				if(window.XMLHttpRequest){
					xhr= new XMLHttpRequest();
				}else{
					xhr=new ActiveXObject("Microsoft.XMLHttp");
				}

				xhr.open("get","php/1.txt","true");
				xhr.send();

				xhr.onreadystatechange=function(){
					if(xhr.readyState==4){
					if(xhr.readyState==4){
						if(xhr.status==200){
							alert(xhr.responseText);
						}else{
							alert(xhr.status)
						}
					}
				}
			}
		}
	}
	</script>
</head>
<body>
	<button id="btn">获取</button>
</body>
</html>